package com.example.ims.service;

import com.example.ims.repository.CommodityRepository;
import com.example.ims.service.inf.SupplierServiceInf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Optional;
import com.example.ims.pojo.Supplier;
import com.example.ims.repository.SupplierRepository;

@Service
@Transactional
public class SupplierService  implements SupplierServiceInf {
    @Autowired
    public SupplierRepository supplierRepository;

    // 添加供应商的业务逻辑方法
    public void addSupplier(Supplier supplier) {
        supplierRepository.save(supplier);
    }

    // 根据ID查询供应商的业务逻辑方法（可用于后续可能的其他业务逻辑，比如更新、删除等操作时查询供应商信息）
    public Optional<Supplier> findById(Long id) {
        return supplierRepository.findById(id);
    }

    // 查询所有供应商的业务逻辑方法
    public List<Supplier> findAllSuppliers() {
        return supplierRepository.findAll();
    }

    public void deleteSupplierById(Long id) {
        supplierRepository.deleteById(id);
    }
}